class Solution
{
public:
    int findMinArrowShots(vector<vector<int>>& points)
    {
        if (points.empty())
            return 0;

        int n = points.size();
        sort(points.begin(), points.end(), [](vector<int>& a, vector<int>& b)
            {
                return a[1] < b[1];
            });

        int arrows = 1, prev = points[0][1];

        for (int i = 1; i < n; i++)
            if (points[i][0] > prev)
            {
                arrows++;
                prev = points[i][1];
            }

        return arrows;
    }
};